package basic_practice_1020;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
 * @author MemoryC
 * */
public class Main {

	public static void main(String[] args) {

		Scanner scanner=new Scanner(System.in);
		
		List<Long>numbers=new ArrayList<>();
		numbers.add((long) 0);
		numbers.add((long) 0);
		numbers.add((long) 1);
		numbers.add((long) 2);
		
		while(scanner.hasNext()) {
			int n=scanner.nextInt();
			
			if(n>numbers.size()-1) {
				for(int i=numbers.size();i<=n;i++) {
					long ann=Ann(i);
					for(int j=1;i-j>=2;j++) {
						ann-=Cni(i,j)*numbers.get(i-j);
					}
					numbers.add(ann-1);
				}
			}
			
    		System.out.println(numbers.get(n));
		}
		scanner.close();
    }
	
	static long Ann(int n) {
		long A=1;
		for(int i=n;i>1;i--) {
			A*=i;
		}
		return A;
	}
	
	static long Cni(int n,int i) {
		if(i>n/2) {
			return Cni(n, n-i);
		}
		long A=1;
		for(int j=n;j>n-i;j--) {
			A*=j;
		}
		for(int j=i;j>0;j--) {
			A/=j;
		}
		return A;
	}
}